<%--
  Created by IntelliJ IDEA.
  User: lqq
  Date: 2017/6/28
  Time: 12:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<html>
<head>

    <base href="<%=basePath%>">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <script src="jquery/jquery-3.2.1.min.js"></script>
    <script src="bootstrap/js/bootstrap.js"></script>
    <link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css">
    <title>员工信息</title>
</head>
<body>

<div class="container">
    <%--标题--%>
    <div class="row">
        <div class="col-md-12">
            <h1>SSH-CRUP</h1>
        </div>
    </div>
    <%--按钮--%>
    <div class="row">
        <div class="col-md-4 col-md-offset-8">
            <button class="btn btn-primary">新增</button>
            <button class="btn btn-danger">删除</button>
        </div>
    </div>
    <%--表格--%>
    <div class="row">
        <div class="col-md-12">
            <table class="table table-striped table-hover">
                <tr>
                    <th>ID</th>
                    <th>姓名</th>
                    <th>性别</th>
                    <th>年龄</th>
                    <th>部门</th>
                    <th>操作</th>
                </tr>


                <c:choose>
                    <c:when test="${pageInfo.list != null && pageInfo.list.size() > 0}">

                        <c:forEach items="${pageInfo.list}" var="var_emp">
                            <tr>
                                <td>${var_emp.id}</td>
                                <td>${var_emp.name}</td>
                                <td>${var_emp.sex}</td>
                                <td>${var_emp.age}</td>
                                <td>${var_emp.dept.name}</td>
                                <td>
                                    <button class="btn btn-primary">
                                        <span class="glyphicon glyphicon-pencil"></span>
                                        修改
                                    </button>
                                    <button class="btn btn-danger">
                                        <span class="glyphicon glyphicon-trash"></span>
                                        删除
                                    </button>
                                </td>
                            </tr>
                        </c:forEach>
                    </c:when>
                </c:choose>

            </table>
        </div>
    </div>
    <%--分页信息--%>
    <div class="row">
        <div class="col-md-6">
            当前页:${pageInfo.pageNum}&nbsp;&nbsp;&nbsp;
            共${pageInfo.pageNum}/${pageInfo.pages}页
        </div>
        <div class="col-md-6">
            <nav aria-label="Page navigation">
                <ul class="pagination">
                    <li><a href="index?curPage=1">首页</a></li>
                    <c:if test="${pageInfo.hasPreviousPage}">
                        <li>
                            <a href="index?curPage=${pageInfo.pageNum - 1}" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                    </c:if>

                    <c:forEach items="${pageInfo.navigatepageNums}" var="var_page_num">

                        <c:if test="${pageInfo.pageNum == var_page_num}">
                            <li class="active"><a href="index?curPage=${var_page_num}">${var_page_num}</a></li>
                        </c:if>
                        <c:if test="${pageInfo.pageNum != var_page_num}">
                            <li><a href="index?curPage=${var_page_num}">${var_page_num}</a></li>
                        </c:if>
                    </c:forEach>
                    <c:if test="${pageInfo.hasNextPage}">
                        <li>
                            <a href="index?curPage=${pageInfo.pageNum + 1}" aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </c:if>
                    <li><a href="index?curPage=${pageInfo.pages}">尾页</a></li>
                </ul>
            </nav>
        </div>
    </div>
</div>
</body>
</html>
